var packRegTable = function() {
		return {
			init : function() {
				var tableId = "pack_reg_table";
				util.initCheckBox(tableId);
				var checkBoxDivStr = '<div class="checker" onclick="util.selectCheckBox(\'' + tableId + '\', this)"><span><input type="checkbox" class="checkboxes"></span></div>';			
				function queryData(sSource, aoData, fnCallback) {
					aoData.push({
						"name" : "colClientId",
						"value" : $("#id_colClientId").val().trim()
					});
					$.ajax({
						"type" : "post",
						"url" : sSource,
						"dataType" : "json",
						"data" : {
							"aoData" : JSON.stringify(aoData)
						},
						"success" : function(resp) {
							fnCallback(resp);
						}
					});
				};
				
				$('#pack_reg_table').DataTable({
					"processing" : true,
					"serverSide" : true,
					"sAjaxSource" : "main/packRegMng/findPackRegList.mvc",
					"fnServerData" : queryData,
					"pageLength" : 10,
					"sDom" : "<'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>",
					"oLanguage" : util.getDToLanguage(),
					"columns" : [ {
						"data" : "pkId",
						"render" : function(data, type, full, meta) {
							 return checkBoxDivStr;
						},
						"bSortable" : false
					},
					{
						"data" : "packregFlagStr",
						"bSortable" : false,
						"defaultContent" : ""
					},
					{
						"data" : "colClientId",
						"bSortable" : false,
						"defaultContent" : ""
					}, 
					{
						"data" : "updateDate",
						"bSortable" : false,
						"defaultContent" : ""
					},
					{
						"data" : "imsi",
						"bSortable" : false,
						"visible" : false,  //隐藏列
						"defaultContent": ""
					}],
					"fnDrawCallback" : function(oSetting) {
						util.clearSelected(tableId);
					}
				});

				$('#pack_reg_table tbody').on('click', 'tr', function() {
					var table = $('#pack_reg_table').DataTable();
					if ($(this).hasClass('selected')) {
						$(this).removeClass('selected');
					} else {
						table.$('tr.selected').removeClass('selected');
						$(this).addClass('selected');
					}
				});
				
				jQuery('#pack_reg_table .group-checkable').change(function() {
					var set = jQuery(this).attr("data-set");
					var checked = jQuery(this).is(":checked");
					jQuery(set).each(function() {
						if (checked) {
							$($(this).parent()).attr("class", "checked");
						} else {
							$($(this).parent()).removeClass("checked");
						}
					});
					jQuery.uniform.update(set);
				});
				
				//注册点击事件
				$("#pack_reg").click(function(e){
					var d = [];
					d = util.getCheckedData("pack_reg_table");
					if (d.length != 1) {
						util.showModal("#_alertModal", "请选择一条记录进行操作！");
						return false;
					}
					util.showContent("pages/basic/packRegDetail.jsp",{'pkId':d[0].pkId, 
						'colClientId':d[0].colClientId});
				});
				
				//更换终端点击事件
				$("#change_client").click(function(e){
					var d = [];
					d = util.getCheckedData("pack_reg_table");
					if (d.length != 1) {
						util.showModal("#_alertModal", "请选择一条记录进行操作！");
						return false;
					}
					util.showContent("pages/basic/packRegChangeClient.jsp",{'pkId':d[0].pkId, 
						'colClientId':d[0].colClientId});
				});
				// 查询
				$("#btn_query").click(function(e){
					var table = $('#pack_reg_table').DataTable();
					table.draw(true);
				});
			    // 重置
				$("#btn_reset").click(function(e){
					$("#pack_search_form")[0].reset();
				});
				
				$(function(){
					//回车查询
					$('.search-body .my-input').bind('keyup', function(event) {
						if (event.keyCode == "13") {
							//回车执行查询
							$('.search-button #btn_query').click();
						}
					});
				});
			}
		};
}();